//
//  LevelScene.h
//  cocos2dt1
//
//  Created by mmac on 1/17/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "cocos2d.h"


#define BLOCK_TYPE_INIT_NUMBER 10
#define BLOCK_ROW_NUMBER 14
#define BLOCK_COL_NUMBER 8
#define BLOCK_SIZE 32

typedef struct _block_position {
	int i;
	int j;
} block_position;

#define BLOCK_SHIFT_NONE	1
#define BLOCK_SHIFT_LEFT	2
#define BLOCK_SHIFT_RIGHT	3
#define BLOCK_SHIFT_TOP		4
#define BLOCK_SHIFT_BOTTOM	0


@interface LevelScene : Layer {
	TextureAtlas *ta;
	int blocks[BLOCK_ROW_NUMBER][BLOCK_COL_NUMBER];
	block_position selectedBlock;
	block_position anotherBlock;

	int block_left_number;
	int block_type_number;
	int block_shift_direction;
}

+ (id) scene;
+ (id) sceneLevel:(int)level;

- (void) setLevel:(int)level;

- (void) initBlocks;
- (void) drawBlocks;
- (void) shiftBlocks:(block_position)p1 and:(block_position)p2;

- (void) selectBlock:(block_position)p;
- (void) unselectBlock;
- (BOOL) haveSelectedBlock;

- (void) checkPair:(block_position)p1;
- (void) removePair:(block_position)p1;
- (void) doRemovePair;

- (BOOL) blockLineDirect:(block_position)p1 to:(block_position)p2;

- (void) blockLineFrom:(block_position)p1 to:(block_position)p2;
- (void) blockLineClear;

- (void) levelClear;
- (void) testNextPair;
- (void) checkPair:(block_position)p1;
- (BOOL) checkPair:(block_position)p1 with:(block_position)p2 testOnly:(BOOL)test ;

@end
